
//
//  DeviceStatisticViewController.m
//  Rail
//
//  Created by hychen on 2018/5/13.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "DeviceStatisticViewController.h"
#import "DeviceSubViewController.h"
#import "MJCSegmentInterface.h"

@interface DeviceStatisticViewController ()
@property (nonatomic, assign) DeviceStatisticType type;
@end

@implementation DeviceStatisticViewController

- (instancetype)initWithType:(DeviceStatisticType)type {
    if (self = [super init]) {
        if (type == 0) {
            type = 1;
        }
        _type = type;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationItem addSimpleTitleView:@"设备统计"];
    
    DeviceSubViewController *menjinVc = [DeviceSubViewController new];
    menjinVc.type = DeviceStatisticTypeRke;
    DeviceSubViewController *talkVc = [DeviceSubViewController new];
    talkVc.type = DeviceStatisticTypeTbk;
    DeviceSubViewController *broadVc = [DeviceSubViewController new];
    broadVc.type = DeviceStatisticTypeBroadcast;
    DeviceSubViewController *locVc = [DeviceSubViewController new];
    locVc.type = DeviceStatisticTypeLocal;
    DeviceSubViewController *evnVc = [DeviceSubViewController new];
    evnVc.type = DeviceStatisticTypeEnv;
    DeviceSubViewController *heaVc = [DeviceSubViewController new];
    heaVc.type = DeviceStatisticTypeHeavy;
    
    menjinVc.areaId = self.areaId;
    talkVc.areaId = self.areaId;
    broadVc.areaId = self.areaId;
    locVc.areaId = self.areaId;
    evnVc.areaId = self.areaId;
    heaVc.areaId = self.areaId;
    
    NSArray *vcArray = @[menjinVc,talkVc,broadVc,locVc,evnVc,heaVc];
    NSArray *titleArray = @[@"门禁",@"对讲",@"广播",@"定位",@"环境",@"重型"];
    NSInteger index = self.type>0?self.type-1:0;
    MJCSegmentInterface *interface = [MJCSegmentInterface jc_initWithFrame:CGRectMake(0,0,self.view.jc_width, self.view.jc_height-kStatusBarAndNavBarHeight) interFaceStyleToolsBlock:^(MJCSegmentStylesTools *jc_tools) {
        jc_tools.
        jc_titlesViewFrame(CGRectMake(0, 0, self.view.jc_width, 40)).
        jc_childScollEnabled(YES).
        jc_itemBackColor([UIColor whiteColor]).
        jc_childScollAnimalEnabled(YES).
        jc_itemTextSelectedColor(Color_RGB(0, 193, 224)).
        jc_itemTextNormalColor(Color_RGB(130, 130, 130)).
        jc_itemTextFontSize(14).
        jc_indicatorStyles(MJCIndicatorItemTextStyle).
        jc_indicatorColor(Color_RGB(0, 193, 224)).
        //默认选中
        jc_itemSelectedSegmentIndex(index).
        jc_indicatorHidden(NO);
    }];
    
    [self.view addSubview:interface];
    [interface intoTitlesArray:titleArray intoChildControllerArray:vcArray hostController:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
